<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>计次消费</title>
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/reset.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/common.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/FontAwesome/css/font-awesome.min.css">
<!--公共样式结束-->
<!--页面样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/module_form.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/page_jiciList.css">
<!--页面样式结束--
<!--公共JS开始-->
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.min.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/jquery.timer.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Js/common.js"></script>
<!--公共JS结束-->
<!--数据列表插件开始-->
<link href="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.contextMenu.css" rel="stylesheet" type="text/css" />
<script src="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.ui.position.js"></script>
<script src="{$NOW_THEME_URL}/Assets/Plugins/ContextMenu/src/jquery.contextMenu.js"></script>
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/Etgrid/Css/etgrid.css">
<script src="{$NOW_THEME_URL}/Assets/Plugins/Etgrid/Js/etgrid.js"></script>
<!--数据列表插件结束-->
<style type="text/css">
	body {
		overflow:hidden;
	}
</style>
</head>

<body>
	<div class="yhlist clearfix">
		<div class="table_box1">
			<table cellpadding="0" cellspacing="0" class="module_form" width="100%">
				<tr>
					<th class="center">计次项目</th>
					<th class="center">可用次数</th>
					<th class="center">剩余次数</th>
					<th class="center">备注</th>
					<th class="center" colspan="2">操作</th>
				</tr>
				<tbody class="table_list_2">
				</tbody>
			</table>
		</div>
		<div class="xiaofei">
			<div class="js clearfix">
				<div>
					<a class="form_ele_reset bg_orange" id="readcard">读卡</a>
					<a class="form_ele_reset" id="clear">清空</a>
				</div>
				<div><input type="text" id="cardno"  class="redecard_input"/></div>
			</div>
			<!-- <div class="zhezhao"></div> -->
			<div class="vip">
				<h4>会员信息</h4>
				<table cellpadding="0" cellspacing="0" class="module_form" width="100%">
					<tr>
						<td class="ele_title"><label for="cardnum">会员卡号：</label></td>
						<td class="ele_content"><input type="text" id="cardnum" class="form_ele_text width_200" readonly/></td>
						<td class="ele_title"><label for="level">邮箱：</label></td>
						<td class="ele_content"><input type="text" id="email" class="form_ele_text width_200" readonly /></td>
					</tr>
					<tr>
						<td class="ele_title"><label for="realname">姓名：</label></td>
						<td class="ele_content"><input name="" type="text" id="realname" class="form_ele_text width_200" value="{$cusArr.realname}" readonly /></td>
						<td class="ele_title"><label for="sex">性别：</label></td>
						<td class="ele_content"><input name="" type="text" id="sex" class="form_ele_text width_200" value="{$cusArr.sex}" readonly /></td>
					</tr>
					<tr>
						<td class="ele_title"><label for="phone">手机号码：</label></td>
						<td class="ele_content"><input name="" type="text" id="phone" class="form_ele_text width_200" value="{$cusArr.mobile}" readonly /></td>
						<td class="ele_title"><label for="telphone">固定电话：</label></td>
						<td class="ele_content"><input name="" type="text" id="telphone" class="form_ele_text width_200" value="{$cusArr.phone}" readonly /></td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
	
	//表格隔行换色
	$('.module_form tr:odd').addClass('odd');
	$('.module_form tr:even').addClass('even');
	
	//列表自适应
	function table_box1Show(){
		var yh_height =  $(window).height() - 200;
		$('.table_box1').height(yh_height);
	}
	//初始化调用
	table_box1Show();
	//窗口改变大小调用
	$(window).on('resize',function(){
		table_box1Show();
	});
	
	$("#readcard").on("click",function(){
		var vipno   = $("#cardno").val();
		var cardnum = $("#cardnum").val();
		if(vipno==""){
			windowApi.lhgdialog.alert('请输入会员卡卡号或者电话号码！');
		}else{
			if(cardnum==""){
				var html = '';
				$.get("{:U('Sell/sellNum')}",{vipno:vipno},function(d){
					
					if(d.cusInfo==null){
						windowApi.lhgdialog.alert("没有找到该会员卡号，请确认是否输入错误");
						$(".zhezhao").hide();
					}else{
						$("#cardnum").val(d.cusInfo['vipno']);
						$("#email").val(d.cusInfo['email']);
						$("#realname").val(d.cusInfo['realname']);
						if(d.cusInfo['sex']==1) $("#sex").val("男");
						else                    $("#sex").val("女");
						
						$("#phone").val(d.cusInfo['mobile']);
						$("#telphone").val(d.cusInfo['phone']);
						$(".zhezhao").hide();
						$.each(d.sellInfo,function(i){
							html += '<tr>';
							html += '<td class="center">'+d.sellInfo[i]['title']+'</td>';
							html += '<td class="center">'+d.sellInfo[i]['amount']+'</td>';
							html += '<td class="center">'+d.sellInfo[i]['remain']+'</td>';
							html += '<td class="center">'+d.sellInfo[i]['content']+'</td>';
							html += '<td><a id="nowxf"  class="form_ele_submit" rel="'+d.sellInfo[i]['id']+'" >立即消费</a></td>';
							html += '<td><a id="chakan" class="form_ele_submit" rel="'+d.sellInfo[i]['id']+'" >查看日志</a></td>';
							html += '<tr>';
						});
						
						$(".table_list_2").append(html);
						$(".zhezhao").hide();
					}
					
				});
			}else{
				windowApi.lhgdialog.alert('请不要重复读卡,先清空之后在读卡！');
			}
		}
		
	});
	
	//打开立即消费
	$('#nowxf').live('click',function(){
		var id = $(this).attr("rel");
		var href = '__URL__/sellNumExpense/id/'+id;
		var width = '380px';
		var height = '280px';
		var title = '立即消费';
		openDialog('Sell_sellNumExpense',href,width,height,title);
	});
	
	//查看消费日志
	$('#chakan').live('click',function(){
		var numid = $(this).attr("rel");   //消费项目编号
		var vipno = $("#cardno").val();  
		var href = '__URL__/numberLog/numid/'+numid+'/vipno/'+vipno;
		var width = '600px';
		var height = '400px';
		var title = '计次消费日志';
		openDialog('Sell_numberLog',href,width,height,title);
	});
	
	//清空
	$('#clear').on('click',function(){
		$("#cardnum").val("");
		$("#email").val("");
		$("#realname").val("");
		$("#sex").val("");
		$("#phone").val("");
		$("#telphone").val("");
		$("#cardno").val("");
		$(".table_list_2>tr").remove();
		$(".zhezhao").show();
	});
	
</script>
</html>
